﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace UrTransPayloadWpf
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class AlertBox : Window
    {
        private DispatcherTimer timer;

        public AlertBox()
        {
            InitializeComponent();
            

        }

        public AlertBox(string label,string caption)
        {
            InitializeComponent();
            TipLabel.Content = label;
            if (caption != "") captionLabel.Content = caption;
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += timer1_Tick;
            timer.Start();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            timer.Stop();
            this.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //定时处理
            this.Activate();
            this.Topmost = true;
        }
    }
}
